﻿using AutoMapper;
using SmartConference.Api.Applocations.IServices;
using SmartConference.Api.DTO;
using SmartConference.Domain;
using SmartConference.ErrorCode;
using SmartConference.Infrastructure.Interfaces;

namespace SmartConference.Api.Applocations.Services
{
    public class PermissionServices : IPermissionServices
    {
        private readonly IPermissionRepository permissionRepository;
        private readonly IMapper mapper;

        public PermissionServices(IPermissionRepository permissionRepository, IMapper mapper)
        {
            this.permissionRepository = permissionRepository;
            this.mapper = mapper;
        }
        public async Task<ApiResult<List<GetPermissionDTO>>> GetPermission()
        {
            try
            {
                var list = permissionRepository.GetAll().ToList();
                var newlist=mapper.Map<List<GetPermissionDTO>>(list);
                return ApiResult<List<GetPermissionDTO>>.Success(ApiResultCode.Success, newlist);
            }
            catch (Exception)
            {

                throw;
            }
        }
    }
}
